package com.dgshanger.sanhxiaofeisc.ui.person

import com.dgshanger.sanhxiaofeisc.R
import com.dgshanger.sanhxiaofeisc.entity.InvoiceEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.InvoiceAssistantContract
import com.dgshanger.sanhxiaofeisc.mvp.presenter.InvoiceAssistantPresenter
import com.xx.baseuilibrary.mvp.BaseMvpActivity
import kotlinx.android.synthetic.main.activity_invoice_assistant.*


/**
 * InvoiceAssistantActivity
 * 沉迷学习不能自拔
 * Describe：发票助手页面
 * Created by 雷小星🍀 on 2018/4/16 11:06.
 */
class InvoiceAssistantActivity : BaseMvpActivity<InvoiceAssistantContract.Model, InvoiceAssistantContract.View, InvoiceAssistantPresenter>(),
        InvoiceAssistantContract.View {

    override fun setInvoiceEntity(entity: InvoiceEntity?) {
        with(entity!!) {
            et_invoice_header.setText(inv_header)
            et_invoice_company_name.setText(inv_company_name)
            et_invoice_base_account.setText(inv_base_account)
            et_invoice_bank_name.setText(inv_bank_name)
            et_invoice_tax_number.setText(inv_tax_number)
            et_invoice_register_number.setText(inv_register_number)
            et_invoice_mobile.setText(inv_mobile)
            et_invoice_address.setText(inv_address)
        }
    }

    override fun getInvoiceHeader(): String = et_invoice_header.text.toString().trim()

    override fun getInvoiceCompanyName(): String = et_invoice_company_name.text.toString().trim()

    override fun getInvoiceBaseAccount(): String = et_invoice_base_account.text.toString().trim()

    override fun getInvoiceBankName(): String = et_invoice_bank_name.text.toString().trim()

    override fun getInvoiceTaxNumber(): String = et_invoice_tax_number.text.toString().trim()

    override fun getInvoiceRegisterNumber(): String = et_invoice_register_number.text.toString().trim()

    override fun getInvoiceMobile(): String = et_invoice_mobile.text.toString().trim()

    override fun getInvoiceAddress(): String = et_invoice_address.text.toString().trim()

    override fun createPresenter(): InvoiceAssistantPresenter = InvoiceAssistantPresenter()

    override fun getActivityLayoutId(): Int = R.layout.activity_invoice_assistant

    override fun initData() {
        getPresenter().myInv()
    }

    override fun initEvent() {
        tv_save.setOnClickListener {
            //保存
            getPresenter().myInvStore()
        }
    }
}